package control;

// : control/LabeledWhile.java
// While loops with "labeled break" and "labeled continue."
import static net.mindview.util.Print.print;

/**
 * 标签用于while循环
 * @title LabeledWhile
 * @author liujiaze@zbj.com
 * @date 2017年7月28日 下午4:23:20
 * @since v1.0.1
 */
public class LabeledWhile {
    public static void main(String[] args) {
        int i = 0;
        outer: while (true) {
            print("Outer while loop");
            while (true) {
                i++;
                print("i = " + i);
                if (i == 1) {
                    print("continue");
                    continue;
                }
                if (i == 3) {
                    print("continue outer");
                    continue outer;
                }
                if (i == 5) {
                    print("break");
                    break;
                }
                if (i == 7) {
                    print("break outer");
                    break outer;
                }
            }
        }
    }
} /*
   * Output:
   * Outer while loop
   * i = 1
   * continue
   * i = 2
   * i = 3
   * continue outer
   * Outer while loop
   * i = 4
   * i = 5
   * break
   * Outer while loop
   * i = 6
   * i = 7
   * break outer
   */// :~
